/**
 * @Title: integrityArtificialScore_ctrl.js
 * @Description: TODO
 * Copyright: Copyright (c) 2015
 * Company:中国平安
 *
 * @Project mhis-hcpms-330
 * @author EX-XIEYUWEN001
 * @date 2015年2月12日 上午11:08:07
 * @version V1.0
 */
;
(function(){
	'use strict';	
	var app = angular.module('fwa.mainApp');
	app.controller('IntegrityApproveCtrl', ['$scope','$http','$modalInstance','$stateParams','BaseURL','Modal','FwaTabsetService','IntegrityMedicalService','CommunityService','WarningScreenService','IntegrityArtificialScoreService','$modal',
	                              function($scope,$http,$modalInstance,$stateParams,baseUrl,Modal,FwaTabsetService,IntegrityMedicalService,CommunityService,WarningScreenService,IntegrityArtificialScoreService,$modal){
		var params = function(){
			var startDate = "";
			if(IntegrityMedicalService.startDate&&!angular.isUndefined(IntegrityMedicalService.startDate)){
				startDate = IntegrityMedicalService.startDate;
			}
			var endDate="";
			if(IntegrityMedicalService.endDate&&!angular.isUndefined(IntegrityMedicalService.endDate)){
				endDate = IntegrityMedicalService.endDate;
			}
			var taskNo="";
			if(IntegrityMedicalService.taskNo&&!angular.isUndefined(IntegrityMedicalService.taskNo)){
				taskNo = IntegrityMedicalService.taskNo;
			}
			var saveStatus="";
			if(IntegrityMedicalService.saveStatus&&!angular.isUndefined(IntegrityMedicalService.saveStatus)){
				saveStatus = IntegrityMedicalService.status;
			}
			var updatedBy="";
			if(IntegrityMedicalService.updatedBy&&!angular.isUndefined(IntegrityMedicalService.updatedBy)){
				updatedBy = IntegrityMedicalService.updatedBy;
			}
			var params = {
					startDate:startDate,
					endDate:endDate,
					taskNo:taskNo,
					saveStatus:saveStatus,
					updatedBy:updatedBy
			}
			return params;
		};
		IntegrityMedicalService.getIntegrityAuditDetail(params()).
		success(function(res){
			$scope.doctorName = IntegrityMedicalService.doctorName;
			$scope.startDate = IntegrityMedicalService.startDate;
			$scope.endDate = IntegrityMedicalService.endDate;
			$scope.auditInfo = res;
				$scope.auditOpinion = res.auditOpinion;
				$scope.opinionContent = res.opinionContent;
				$scope.auditInfo.auditOpinion = null;
				$scope.auditInfo.opinionContent = null;
		});
		//获取总分
		   WarningScreenService.getPointScose({targetNo:IntegrityMedicalService.doctorCode}).
			success(function(res){
				if(res.pointScose){
					$scope.orgContentPoint = res.pointScose;//考核内容已记分值
					$scope.deductionScores = parseFloat(res.pointScose).toFixed(1);
				}else{
					$scope.orgContentPoint = null;
				}
			});
		   
			//关闭
			$scope.onClose = function(){
	    		$modalInstance.dismiss();
	    	}
			$scope.audit = function(){
				var params = {
						taskNo:IntegrityMedicalService.taskNo,
						opinionType:'02',
						opinion:$scope.auditInfo.auditOpinion,
						opinionDesc:$scope.auditInfo.opinionContent,
						actCurrent:$scope.auditInfo.actCurrent,
						saveStatus:IntegrityMedicalService.saveStatus
				};
				var shpConfirm = '确认审批吗？',
					shpConfirmStr = '审批通过！',
					shpConfirmFail = '审批失败！';
                Modal.confirm(shpConfirm,function() {
                    $http.post(baseUrl + 'doctorIntegrity/approveConfirm.do', params).success(function (data) {
                        if (data.state == '0') {
                            Modal.alert(shpConfirmStr);
                            $modalInstance.close(true);
                        } else {
                            Modal.alert(shpConfirmFail);
                        }
                    })
                })
			}
		
	}]).controller('IntegrityApproveBatchCtrl', ['$scope','$http','$modalInstance','$stateParams','BaseURL','Modal','FwaTabsetService','IntegrityMedicalService','CommunityService','WarningScreenService','IntegrityArtificialScoreService','$modal',
	                              function($scope,$http,$modalInstance,$stateParams,baseUrl,Modal,FwaTabsetService,IntegrityMedicalService,CommunityService,WarningScreenService,IntegrityArtificialScoreService,$modal){
			$scope.startDate = "";
			if(IntegrityMedicalService.startDate&&!angular.isUndefined(IntegrityMedicalService.startDate)){
			$scope.startDate = IntegrityMedicalService.startDate;
			}
			$scope.endDate="";
			if(IntegrityMedicalService.endDate&&!angular.isUndefined(IntegrityMedicalService.endDate)){
			$scope.endDate = IntegrityMedicalService.endDate;
			}
			var batchTaskNos= [];
			if(IntegrityMedicalService.batchTaskNos&&!angular.isUndefined(IntegrityMedicalService.batchTaskNos)){
				batchTaskNos = IntegrityMedicalService.batchTaskNos;
			}
			var actCurrent="";
			if(IntegrityMedicalService.actCurrent&&!angular.isUndefined(IntegrityMedicalService.actCurrent)){
				actCurrent = IntegrityMedicalService.actCurrent;
			}
			var shpConfirm = '确认审批吗？',
				shpConfirmStr = '审批通过！',
				shpConfirmFail = '审批失败！';
			
			//关闭
			$scope.onClose = function(){
	    		$modalInstance.dismiss();
	    	};
	    	$scope.auditInfo = {}
			$scope.audit = function(){
				var params = {
						batchTaskNos:IntegrityMedicalService.batchTaskNos,
						opinionType:'02',
						opinion:$scope.auditInfo.auditOpinion,
						opinionDesc:$scope.auditInfo.opinionContent,
						actCurrent:actCurrent,
						saveStatus:IntegrityMedicalService.saveStatus
				};
                Modal.confirm(shpConfirm,function() {
                    $http.post(baseUrl + 'doctorIntegrity/approveBatchConfirm.do', params).success(function (data) {
                        if (data.state == '0') {
                            Modal.alert(shpConfirmStr);
                            $modalInstance.close(true);
                        } else {
                            Modal.alert(shpConfirmFail);
                        }
                    })
                })
			}
			
		
	}]);
})();
	